package com.example.rocket_mq.listener;

import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Classname: Consumer
 * @Description: RocketMQ消费者监听器
 * @Date: 2021/5/24
 * @Author: huwei
 *
 * 消费者类要实现RocketMQ的RocketMQListener类并加上@RocketMQMessageListener注解
 *
 * @RocketMQMessageListener注解两个属性:
 * topic(生产者的消息标题)
 * consumerGroup(配置文件中消费者组名)
 */
@RocketMQMessageListener(topic = "producerMsg",consumerGroup = "${rocketmq.consumer.group}")
@Component
public class Consumer implements RocketMQListener<String> {
    @Override
    public void onMessage(String s) {
        System.out.println("接收到消息:"+s);
    }
}
